package com.wanaofu.service;

import java.util.List;

import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;

import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import com.wanaofu.dao.QueryDAO;
import com.wanaofu.dao.UniversalDAO;
import com.wanaofu.model.UserInfo;
import com.wanaofu.model.Warehouse;

@Service
@Validated
public class WarehouseService {
	@Resource
	private UniversalDAO uidDAO ;
	@Resource
	private QueryDAO queryDao ;
	
	public UserInfo getUserInfoByID(String id) {
		return queryDao.findEntityByID(UserInfo.class, id) ;
	}
	
	public void saveWarehouse(@NotNull(message="Input must not be null or empty.")@Valid Warehouse wh)  {
		uidDAO.save(wh);
	}
	public void deleteWarehouse(Warehouse user)  {
		uidDAO.delete(user);
	}
	
	public boolean exitsWarehouseByWareCode(String wareCode){
		List<Warehouse> warehouse = queryDao.findWareHouseByCode(wareCode);
		if(warehouse!=null&&warehouse.size()>0){
			return true;
		}
		return false;
	}

	public Warehouse getWarehouseByCode(String wCode,String areaCode,String shelfCode,String floorCode){
		return queryDao.findWareHouseByCode(wCode,areaCode,shelfCode,floorCode);
	}
	

	public void saveUserInfo(@NotNull(message="Input must not be null or empty.")UserInfo user)  {
		uidDAO.save(user);
	}
	
	public UserInfo getUserInfoByCode(String uCode) {
		return queryDao.findUserInfoByCode(uCode);
	}
}
